﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.CycleTimeReport.CApCTREventsCalc
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Olp.PrivateImplementationDetails;


namespace DnProcessSimulateCommands.CycleTimeReport;

public class CApCTREventsCalc
{
  public const int DEFAULT_CYCLE_NUMBER = 0;
  public const double EPSILON_TIME = 0.0001;
  public const string FULL_ARRIVAL_TIMER = "FullArrival";
  public const string DUMMY_TIMER = "Dummy";
  public const string WELDING_TIME_TIMER = "WeldingTime";
  private bool m_debugMode;
  private List<string> m_lines = new List<string>();
  private StreamWriter m_writer;
  private string m_path = "C:\\Temp\\CycleTimeAlgoritem.txt";

  internal CApCTREventsCalc(bool debugMode = false)
  {
    this.PausedEventList = new List<TxOlpCTREventInfo>();
    this.RunEventList = new List<TxOlpCTREventInfo>();
    this.TimersList = new List<CApCTRTimer>();
    this.m_debugMode = debugMode;
    if (this.m_debugMode && File.Exists(this.m_path))
      File.Delete(this.m_path);
    this.CycleNumber = 0;
  }

  private void MarkOriginalIndex()
  {
    for (int index = 0; index < this.AllEventList.Count; ++index)
      this.AllEventList[index].OriginalEventIndex = index * 10;
  }

  internal List<CApCTRTimer> Calc(
    List<TxOlpCTREventInfo> eventList,
    out int cycleNumber,
    out string programNumber)
  {
    this.AllEventList = eventList;
    this.MarkOriginalIndex();
    this.PrintAllEventList();
    this.FocusOnLastFullCycle();
    if (eventList.Count > 0)
    {
      if (this.AllEventList[0].Status == null && this.AllEventList[0].EventName == "MotionToLocation")
        this.TryToFindItsPairInSilentSimulationEvent(this.AllEventList[0]);
      this.RunEventList.Add(this.AllEventList[0]);
      this.AllEventList.RemoveAt(0);
      this.PrintStep(this.RunEventList[0], true);
      for (int index = 0; index < this.AllEventList.Count - 1; ++index)
      {
        TxOlpCTREventInfo allEvent = this.AllEventList[index];
        this.PrintStep(allEvent, false);
        int itsPairIndex = -1;
        this.TryToFindItsPair(allEvent, ref itsPairIndex, this.RunEventList);
        if (itsPairIndex > -1)
        {
          this.HandlePairCaseInRunEventList(allEvent, itsPairIndex);
          this.PrintAfterStep();
        }
        else
        {
          this.TryToFindItsPair(allEvent, ref itsPairIndex, this.PausedEventList);
          if (itsPairIndex > -1)
          {
            this.HandlePairCaseInPausedEventList(allEvent, itsPairIndex);
            this.PrintAfterStep();
          }
          else
          {
            this.HandleNestedCase(allEvent);
            this.PrintAfterStep();
          }
        }
      }
      this.StopAllRunEventList();
      this.StopAllPausedEventList();
    }
    this.PrintMessage("TimersList - before sort");
    this.PrintTimersList();
    if (this.TimersList.Count > 1)
    {
      this.TimersList.Sort(new Comparison<CApCTRTimer>(this.CompareCApCTRTimerByTime));
      this.HandelCircularMotion();
      this.PrintMessage("TimersList - before FullArriaval timers merge");
      this.PrintTimersList();
      this.MergeConsecutiveFullArriavalTimers();
      this.PrintMessage("TimersList - before Split Motion Timer and Weld/Wait timers");
      this.PrintTimersList();
      this.SplitMotionAndWeldTimers();
      this.PrintMessage("TimersList - before duplicate Dummy timers merge");
      this.PrintTimersList();
      this.MergeDummyTimers();
      this.PrintMessage("TimersList - before Consecutive Dummy timers merge");
      this.PrintTimersList();
      this.MergeConsecutiveDummyTimers();
      this.PrintMessage("TimersList - before Preliminary Dummy timers merge");
      this.PrintTimersList();
      this.MergePreliminarDummyTimers();
    }
    this.PrintMessage("TimersList - final");
    this.PrintTimersList();
    if (this.m_debugMode)
    {
      this.m_writer.Close();
      this.m_writer = (StreamWriter) null;
    }
    cycleNumber = this.CycleNumber;
    programNumber = this.ProgramNumber;
    return this.TimersList;
  }

  private void TryToFindItsPairInSilentSimulationEvent(TxOlpCTREventInfo current)
  {
    foreach (TxOlpCTREventInfo txOlpCtrEventInfo in TxOlpRoboticSimulationEventsManager.Instance.SilentSimulationEventData)
    {
      if (txOlpCtrEventInfo.Equals(current) && txOlpCtrEventInfo.Status == 1 && current.Status == null && txOlpCtrEventInfo.EventObject1 == current.EventObject1 && current.Status == null)
      {
        this.AllEventList.Insert(0, txOlpCtrEventInfo);
        break;
      }
    }
  }

  private void HandelCircularMotion()
  {
    for (int index = 1; index < this.TimersList.Count<CApCTRTimer>(); ++index)
    {
      CApCTRTimer timers1 = this.TimersList[index - 1];
      CApCTRTimer timers2 = this.TimersList[index];
      if (TxDoubleExtension.AlmostEquals(timers1.StartTime, timers2.StartTime, 0.0001) && TxDoubleExtension.AlmostEquals(timers1.EndTime, timers2.EndTime, 0.0001) && timers1.Name == timers2.Name && timers2.Name == "MotionToLocation")
        timers1.ActiveDuration = 0.0;
    }
  }

  private int CompareCApCTRTimerByTime(CApCTRTimer x, CApCTRTimer y)
  {
    if (TxDoubleExtension.AlmostEquals(x.StartTime, y.StartTime, 0.0001))
    {
      if (x.OriginalEventIndex == y.OriginalEventIndex)
        return 0;
      return x.OriginalEventIndex < y.OriginalEventIndex ? -1 : 1;
    }
    return x.StartTime < y.StartTime ? -1 : 1;
  }

  private void FocusOnLastFullCycle()
  {
    int num1 = 0;
    int num2 = 0;
    int index1 = 0;
    for (int index2 = 0; index2 < this.AllEventList.Count; ++index2)
    {
      if (this.AllEventList[index2] is TxOlpCTRCycleEventInfo && this.AllEventList[index2].Status == 1)
      {
        this.ProgramNumber = (this.AllEventList[index2] as TxOlpCTRCycleEventInfo).ProgramNumber;
        num1 = index2;
        if (index2 - 1 < this.AllEventList.Count)
        {
          for (int index3 = index2 + 1; index3 < this.AllEventList.Count; ++index3)
          {
            if (this.AllEventList[index3] is TxOlpCTRCycleEventInfo && this.AllEventList[index3].Status == null)
            {
              num2 = index2;
              index1 = index3;
              index2 = index3;
              ++this.CycleNumber;
              break;
            }
          }
        }
      }
    }
    List<TxOlpCTREventInfo> collection = new List<TxOlpCTREventInfo>();
    if (num2 < index1)
    {
      for (int index4 = num2 + 1; index4 < index1; ++index4)
        collection.Add(this.AllEventList[index4]);
      TxOlpCTRSystemEventInfo ctrSystemEventInfo = new TxOlpCTRSystemEventInfo("EndOfSimulation", (TxOlpCTREventStatus) 0, this.AllEventList[index1].EventTime);
      collection.Add((TxOlpCTREventInfo) ctrSystemEventInfo);
      this.AllEventList.Clear();
      this.AllEventList.AddRange((IEnumerable<TxOlpCTREventInfo>) collection);
    }
    if (this.m_debugMode)
      this.m_writer.WriteLine("Last Cycle in Line Simulation:");
    this.PrintAllEventList();
  }

  private void StopAllRunEventList()
  {
    if (this.AllEventList.Count == 0)
    {
      this.PrintMessage("StopAllRunEventList - Event list is empty.");
    }
    else
    {
      int index = this.AllEventList.Count - 1;
      if (this.RunEventList.Count <= 0)
        return;
      this.PrintStep(this.AllEventList[index], false);
      foreach (TxOlpCTREventInfo runEvent in this.RunEventList)
      {
        double num = this.AllEventList[index].EventTime - runEvent.EventTime;
        runEvent.ActiveDuration += num;
        this.TimersList.Add((CApCTRTimer) new CApCTRTimerSupportPriority(runEvent.EventName, runEvent.OriginalEventIndex, runEvent.OriginalEventTime, this.AllEventList[index].OriginalEventTime, runEvent.ActiveDuration, runEvent.Description, runEvent.EventObject1, runEvent.EventObject2, runEvent.EventObject3, runEvent.Robot, runEvent.Priority, true));
      }
      this.RunEventList.Clear();
      this.PrintAfterStep();
    }
  }

  private void StopAllPausedEventList()
  {
    if (this.AllEventList.Count == 0)
    {
      this.PrintMessage("StopAllPausedEventList - Event list is empty.");
    }
    else
    {
      int index = this.AllEventList.Count - 1;
      if (this.PausedEventList.Count <= 0)
        return;
      this.PrintStep(this.AllEventList[index], false);
      foreach (TxOlpCTREventInfo pausedEvent in this.PausedEventList)
        this.TimersList.Add((CApCTRTimer) new CApCTRTimerSupportPriority(pausedEvent.EventName, pausedEvent.OriginalEventIndex, pausedEvent.OriginalEventTime, this.AllEventList[index].OriginalEventTime, pausedEvent.ActiveDuration, pausedEvent.Description, pausedEvent.EventObject1, pausedEvent.EventObject2, pausedEvent.EventObject3, pausedEvent.Robot, pausedEvent.Priority, true));
      this.PausedEventList.Clear();
      this.PrintAfterStep();
    }
  }

  private void TryToFindItsPair(
    TxOlpCTREventInfo newEvent,
    ref int itsPairIndex,
    List<TxOlpCTREventInfo> EventList)
  {
    for (int index = 0; index < EventList.Count; ++index)
    {
      if (EventList[index].Equals(newEvent) && EventList[index].Status == 1 && newEvent.Status == null)
      {
        itsPairIndex = index;
        break;
      }
    }
  }

  private void HandleNestedCase(TxOlpCTREventInfo newEvent)
  {
    List<int> intList = new List<int>();
    bool flag = true;
    for (int index = 0; index < this.RunEventList.Count; ++index)
    {
      if (this.RunEventList[index].Priority > newEvent.Priority)
      {
        intList.Add(index);
        flag = true;
        double num = newEvent.EventTime - this.RunEventList[index].EventTime;
        this.RunEventList[index].ActiveDuration += num;
      }
      else if (this.RunEventList[index].Priority < newEvent.Priority)
      {
        this.InsertToPausedEventList(newEvent);
        flag = false;
        break;
      }
    }
    if (intList.Count > 0)
    {
      foreach (int index in intList)
      {
        this.RunEventList[index].EventTime = newEvent.EventTime;
        this.InsertToPausedEventList(this.RunEventList[index]);
      }
      for (int index = this.PausedEventList.Count - intList.Count; index < this.PausedEventList.Count; ++index)
        this.RunEventList.Remove(this.PausedEventList[index]);
    }
    if (!flag || newEvent.Status != 1)
      return;
    this.RunEventList.Add(newEvent);
  }

  private void InsertToPausedEventList(TxOlpCTREventInfo eventToInsert)
  {
    int index1 = -1;
    for (int index2 = 0; index2 < this.PausedEventList.Count; ++index2)
    {
      if (this.PausedEventList[index2].Equals(eventToInsert) && this.PausedEventList[index2].Status + eventToInsert.Status == 1)
      {
        index1 = index2;
        break;
      }
    }
    if (index1 == -1)
    {
      this.PausedEventList.Add(eventToInsert);
    }
    else
    {
      this.TimersList.Add((CApCTRTimer) new CApCTRTimerSupportPriority(this.PausedEventList[index1].EventName, this.PausedEventList[index1].OriginalEventIndex, this.PausedEventList[index1].OriginalEventTime, eventToInsert.OriginalEventTime, this.PausedEventList[index1].ActiveDuration, this.PausedEventList[index1].Description, this.PausedEventList[index1].EventObject1, this.PausedEventList[index1].EventObject2, this.PausedEventList[index1].EventObject3, this.PausedEventList[index1].Robot, this.PausedEventList[index1].Priority));
      this.PausedEventList.RemoveAt(index1);
    }
  }

  private void HandlePairCaseInRunEventList(TxOlpCTREventInfo newEvent, int itsPairIndex)
  {
    TxOlpCTREventInfo runEvent = this.RunEventList[itsPairIndex];
    double num1 = newEvent.EventTime - runEvent.EventTime;
    runEvent.ActiveDuration += num1;
    if (runEvent.EventObject1 is ITxRoboticLocationOperation && !((ITxObject) (runEvent.EventObject1 as ITxRoboticLocationOperation)).IsValid() && runEvent.EventObject1Name != null)
      runEvent.EventObject1 = (object) runEvent.EventObject1Name;
    CApCTRTimer capCtrTimer = !TxOlpRoboticSimulationEventsManager.Instance.SupportPriority(runEvent.EventName) ? new CApCTRTimer(runEvent.EventName, runEvent.OriginalEventIndex, runEvent.OriginalEventTime, newEvent.OriginalEventTime, runEvent.ActiveDuration, runEvent.Description, runEvent.EventObject1, runEvent.EventObject2, runEvent.EventObject3, runEvent.Robot) : (CApCTRTimer) new CApCTRTimerSupportPriority(runEvent.EventName, runEvent.OriginalEventIndex, runEvent.OriginalEventTime, newEvent.OriginalEventTime, runEvent.ActiveDuration, runEvent.Description, runEvent.EventObject1, runEvent.EventObject2, runEvent.EventObject3, runEvent.Robot, runEvent.Priority);
    if (runEvent is TxOlpCTRMotionToLocationEventInfo)
      capCtrTimer.AdditionalInfo = (runEvent as TxOlpCTRMotionToLocationEventInfo).AdditionalInfo;
    this.TimersList.Add(capCtrTimer);
    foreach (TxOlpCTREventInfo pausedEvent in this.PausedEventList)
      pausedEvent.EventTime = newEvent.EventTime;
    this.RunEventList.Remove(runEvent);
    if (this.RunEventList.Count != 0)
      return;
    int num2 = int.MaxValue;
    for (int index = 0; index < this.PausedEventList.Count; ++index)
    {
      if (this.PausedEventList[index].Priority < num2)
        num2 = this.PausedEventList[index].Priority;
    }
    List<TxOlpCTREventInfo> txOlpCtrEventInfoList = new List<TxOlpCTREventInfo>();
    for (int index = 0; index < this.PausedEventList.Count; ++index)
    {
      if (this.PausedEventList[index].Priority == num2)
        txOlpCtrEventInfoList.Add(this.PausedEventList[index]);
    }
    foreach (TxOlpCTREventInfo txOlpCtrEventInfo in txOlpCtrEventInfoList)
    {
      if (txOlpCtrEventInfo.Status == 1)
      {
        this.RunEventList.Add(txOlpCtrEventInfo);
        this.PausedEventList.Remove(txOlpCtrEventInfo);
      }
    }
  }

  private void HandlePairCaseInPausedEventList(TxOlpCTREventInfo newEvent, int itsPairIndex)
  {
    TxOlpCTREventInfo pausedEvent = this.PausedEventList[itsPairIndex];
    this.TimersList.Add((CApCTRTimer) new CApCTRTimerSupportPriority(pausedEvent.EventName, pausedEvent.OriginalEventIndex, pausedEvent.OriginalEventTime, newEvent.OriginalEventTime, pausedEvent.ActiveDuration, pausedEvent.Description, pausedEvent.EventObject1, pausedEvent.EventObject2, pausedEvent.EventObject3, pausedEvent.Robot, pausedEvent.Priority));
    this.PausedEventList.Remove(pausedEvent);
  }

  internal bool ShouldMergeMotionTimers(CApCTRTimer primary, CApCTRTimer merge, string testString)
  {
    string str = ((TxOlpCTRInternalEvent) 0).ToString();
    return !(primary.Name != str) && !(merge.Name != str) && merge.Object2 != null && merge.Object2 is string && !(merge.Object2 as string != testString);
  }

  internal bool ShouldMergeConsecutiveMotionTimers(
    CApCTRTimer primary,
    CApCTRTimer consecutive,
    string consecutiveString)
  {
    return this.ShouldMergeMotionTimers(primary, consecutive, consecutiveString);
  }

  internal bool ShouldMergePreliminarMotionTimers(
    CApCTRTimer preliminar,
    CApCTRTimer primary,
    string preliminarString)
  {
    return this.ShouldMergeMotionTimers(primary, preliminar, preliminarString);
  }

  internal void MergeConsecutiveFullArriavalTimers()
  {
    List<CApCTRTimer> capCtrTimerList = new List<CApCTRTimer>();
    capCtrTimerList.Add(this.TimersList[0]);
    for (int index1 = 1; index1 < this.TimersList.Count; ++index1)
    {
      int index2 = capCtrTimerList.Count - 1;
      CApCTRTimer primary = capCtrTimerList[index2];
      CApCTRTimer timers = this.TimersList[index1];
      if (this.ShouldMergeConsecutiveMotionTimers(primary, timers, "FullArrival") && timers.Object1 == primary.Object1 && timers.StartTime == primary.EndTime)
      {
        primary.EndTime = timers.EndTime;
        primary.ActiveDuration += timers.ActiveDuration;
        (primary as CApCTRTimerSupportPriority).InactiveDuration = primary.EndTime - primary.StartTime - primary.ActiveDuration;
        primary.TimerIsStoppedInTheMiddle = timers.TimerIsStoppedInTheMiddle;
        capCtrTimerList[index2] = primary;
      }
      else
        capCtrTimerList.Add(timers);
    }
    this.TimersList = capCtrTimerList;
  }

  internal void SplitMotionAndWeldTimers()
  {
    List<CApCTRTimer> capCtrTimerList = new List<CApCTRTimer>();
    foreach (CApCTRTimer timers in this.TimersList)
    {
      if (timers is CApCTRTimerSupportPriority && timers.AdditionalInfo != null)
      {
        foreach (string str in timers.AdditionalInfo)
        {
          if (str.StartsWith("WeldingTime"))
          {
            char[] separator = new char[1]{ '=' };
            double result;
            double.TryParse(str.Split(separator, StringSplitOptions.RemoveEmptyEntries)[1], out result);
            timers.EndTime -= result;
            timers.ActiveDuration -= result;
            capCtrTimerList.Add(timers);
            CApCTRTimerSupportPriority timerSupportPriority = new CApCTRTimerSupportPriority(((TxOlpCTRInternalEvent) 4).ToString(), timers.OriginalEventIndex + 1, timers.EndTime, result, timers.Robot, (timers as CApCTRTimerSupportPriority).Priority);
            capCtrTimerList.Add((CApCTRTimer) timerSupportPriority);
          }
          else
            capCtrTimerList.Add(timers);
        }
      }
      else
        capCtrTimerList.Add(timers);
    }
    this.TimersList = capCtrTimerList;
  }

  internal void MergeDummyTimers()
  {
    List<CApCTRTimer> capCtrTimerList = new List<CApCTRTimer>();
    capCtrTimerList.Add(this.TimersList[0]);
    for (int index1 = 1; index1 < this.TimersList.Count; ++index1)
    {
      int index2 = capCtrTimerList.Count - 1;
      CApCTRTimer capCtrTimer = capCtrTimerList[index2];
      CApCTRTimer timers = this.TimersList[index1];
      if (this.ShouldMergeConsecutiveMotionTimers(capCtrTimer, timers, "Dummy") && this.ShouldMergePreliminarMotionTimers(capCtrTimer, timers, "Dummy") && capCtrTimer.StartTime <= timers.StartTime && timers.StartTime <= capCtrTimer.EndTime)
      {
        if (capCtrTimer.EndTime < timers.EndTime)
        {
          double num = capCtrTimer.EndTime - timers.StartTime;
          capCtrTimer.ActiveDuration += timers.ActiveDuration - num;
          capCtrTimer.EndTime = timers.EndTime;
        }
        (capCtrTimer as CApCTRTimerSupportPriority).InactiveDuration = capCtrTimer.EndTime - capCtrTimer.StartTime - capCtrTimer.ActiveDuration;
        capCtrTimerList[index2] = capCtrTimer;
      }
      else
        capCtrTimerList.Add(timers);
    }
    this.TimersList = capCtrTimerList;
  }

  internal void MergeConsecutiveDummyTimers()
  {
    List<CApCTRTimer> capCtrTimerList = new List<CApCTRTimer>();
    capCtrTimerList.Add(this.TimersList[0]);
    for (int index1 = 1; index1 < this.TimersList.Count; ++index1)
    {
      int index2 = capCtrTimerList.Count - 1;
      CApCTRTimer primary = capCtrTimerList[index2];
      CApCTRTimer timers = this.TimersList[index1];
      if (this.ShouldMergeConsecutiveMotionTimers(primary, timers, "Dummy") && primary.StartTime <= timers.StartTime && timers.StartTime <= primary.EndTime)
      {
        if (primary.EndTime < timers.EndTime)
        {
          double num = primary.EndTime - timers.StartTime;
          primary.ActiveDuration += timers.ActiveDuration - num;
          primary.EndTime = timers.EndTime;
        }
        (primary as CApCTRTimerSupportPriority).InactiveDuration = primary.EndTime - primary.StartTime - primary.ActiveDuration;
        capCtrTimerList[index2] = primary;
      }
      else
        capCtrTimerList.Add(timers);
    }
    this.TimersList = capCtrTimerList;
  }

  internal void MergePreliminarDummyTimers()
  {
    List<CApCTRTimer> capCtrTimerList = new List<CApCTRTimer>();
    capCtrTimerList.Add(this.TimersList[0]);
    for (int index1 = 1; index1 < this.TimersList.Count; ++index1)
    {
      int index2 = capCtrTimerList.Count - 1;
      CApCTRTimer preliminar = capCtrTimerList[index2];
      CApCTRTimer timers = this.TimersList[index1];
      if (this.ShouldMergePreliminarMotionTimers(preliminar, timers, "Dummy") && preliminar.StartTime <= timers.StartTime && timers.StartTime <= preliminar.EndTime)
      {
        if (preliminar.StartTime < timers.StartTime)
        {
          double num = preliminar.EndTime - timers.StartTime;
          timers.ActiveDuration += preliminar.ActiveDuration - num;
          timers.StartTime = preliminar.StartTime;
        }
        (timers as CApCTRTimerSupportPriority).InactiveDuration = timers.EndTime - timers.StartTime - timers.ActiveDuration;
        capCtrTimerList[index2] = timers;
      }
      else
        capCtrTimerList.Add(timers);
    }
    this.TimersList = capCtrTimerList;
  }

  internal void Clear()
  {
    this.AllEventList.Clear();
    this.PausedEventList.Clear();
    this.RunEventList.Clear();
    this.TimersList.Clear();
    this.CycleNumber = 0;
  }

  private void PrintMessage(string message)
  {
    if (!this.m_debugMode)
      return;
    this.m_writer.WriteLine(message);
  }

  private void PrintStep(TxOlpCTREventInfo current, bool isFirstStep)
  {
    if (!this.m_debugMode)
      return;
    if (isFirstStep)
      this.m_writer.WriteLine("First  Event:");
    else
      this.m_writer.WriteLine("Current Event:");
    this.m_writer.WriteLine(current.ToString());
    this.m_writer.WriteLine("");
    if (!isFirstStep)
      return;
    this.m_writer.WriteLine("***********************************");
  }

  private void PrintAfterStep()
  {
    if (!this.m_debugMode)
      return;
    this.m_writer.WriteLine("");
    this.m_writer.WriteLine("RunEventList:");
    foreach (object runEvent in this.RunEventList)
      this.m_writer.WriteLine(runEvent.ToString());
    this.m_writer.WriteLine("");
    this.m_writer.WriteLine("PausedEventList:");
    foreach (object pausedEvent in this.PausedEventList)
      this.m_writer.WriteLine(pausedEvent.ToString());
    this.m_writer.WriteLine("");
    this.m_writer.WriteLine("TimersList:");
    foreach (object timers in this.TimersList)
      this.m_writer.WriteLine(timers.ToString());
    this.m_writer.WriteLine("");
    this.m_writer.WriteLine("*******************************************************");
  }

  private void PrintTimersList()
  {
    if (!this.m_debugMode)
      return;
    this.m_writer.WriteLine("");
    this.m_writer.WriteLine("TimersList:");
    foreach (object timers in this.TimersList)
      this.m_writer.WriteLine(timers.ToString());
    this.m_writer.WriteLine("");
    this.m_writer.WriteLine("*******************************************************");
  }

  private void PrintAllEventList()
  {
    if (!this.m_debugMode)
      return;
    if (this.m_writer == null)
      this.m_writer = File.AppendText(this.m_path);
    this.m_writer.WriteLine($"{DateTime.Now.ToString()}        AllEventList for robot      {((TxBaseGeometryCreationObject) this.AllEventList[0].Robot).Name}:");
    this.m_writer.WriteLine("");
    foreach (object allEvent in this.AllEventList)
      this.m_writer.WriteLine(allEvent.ToString());
    this.m_writer.WriteLine("*******************************************************");
  }

  internal int CycleNumber { get; set; }

  internal string ProgramNumber { get; set; }

  internal List<TxOlpCTREventInfo> AllEventList { get; set; }

  internal List<TxOlpCTREventInfo> PausedEventList { get; set; }

  internal List<TxOlpCTREventInfo> RunEventList { get; set; }

  internal List<CApCTRTimer> TimersList { get; set; }
}
